import React from "react";
import * as PropTypes from "prop-types";

/**
 * Input Password Component
 */
export default class Password extends React.Component
{
    /**
     * 表单类名
     */
    className = "input";

    /**
     * 默认属性
     */
    static defaultProps =
    {
        label : "",
        class : "",
        name : "",
        value : "",
        style : {},
        placeholder : "",
    };

    static propTypes =
    {
        label : PropTypes.string,
        class : PropTypes.string,
        name : PropTypes.string,
        value : PropTypes.string,
        placeholder : PropTypes.string,
        style : PropTypes.object
    };

    componentWillMount ()
    {
        if (this.props.class) {
            this.className += " " + this.props.class;
        }
    }

    render ()
    {
        return <label className={this.props.class}>
            {this.props.label ? <span className="title">{this.props.label}</span> : ""}
            <input type="password" defaultValue={this.props.value} name={this.props.name} style={this.props.style} className={this.className} placeholder={this.props.placeholder}/>
        </label>
    }
}